
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

///  项目名称：flutter_audit_app
///  Created by leon on 2020/08/23 .

///  近况统计
///

class RecentStatPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => _RecentStatState();
}

class _RecentStatState extends State<RecentStatPage> {
 /* PieChartUtil _pieChartUtil;
  var data1 = DrugPieData(leftTopTitle: '各类就诊途径次数分布');
  var data2 = DrugPieData(leftTopTitle: '各类就诊途径金额分布');
  var data3 = DrugPieData(leftTopTitle: '年度就诊金额及基金支付分布');
  List<DrugPieData> _pieList = [];*/

  @override
  void initState() {
  /*  _pieChartUtil = PieChartUtil(usePercentValuesEnabled: false);
    _pieList..add(data1)..add(data2)..add(data3);*/
    // _testPieData();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(

  /*      child: Column(
//          mainAxisSize: MainAxisSize.min,
          children: [
            Container(
              padding: EdgeInsets.only(left: 30, top: 10),
              child: Row(
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  TitleAndInput(
                    title: '医疗机构名称',
                    hint: '请输入',
                  ),
                  SizedBox(
                    width: 30,
                  ),
                  Text('时间', style: TextStyle(fontSize: 12)),
                  SizedBox(width: 10),
                  _dateWidget('start'),
                  Container(
                    margin: EdgeInsets.only(left: 10, right: 10),
                    child: Text('—'),
                  ),
                  _dateWidget('end'),
                  _searchBtn(),
                ],
              ),
            ),
            Expanded(
              child: Container(
                margin:
                    EdgeInsets.only(left: 30, right: 15, top: 10, bottom: 10),
                child: Row(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Expanded(child: _buildPieListView()),
                    SizedBox(width: width(30)),
                    Expanded(
                      child: Column(
                        children: [
                          _buildListViewHeader(),
                          Expanded(
                            child: _buildListView(),
                          ),
                        ],
                      ),
                    ),
                  ],
                ),
              ),
            ),
          ],
        ),*/
      ),
    );
  }

  ///时间选择栏
  /*Widget _dateWidget(String dateFlag) {
    return InkWell(
      child: Container(
        height: height(40),
        width: width(250),
        decoration: inputBorderBg(),
        padding: EdgeInsets.only(left: 10, right: 5),
        child: Row(
          children: [
            Expanded(
              flex: 1,
              child: Container(
                alignment: Alignment.center,
                width: 10,
                child: Row(
                  children: [
                    Expanded(
                      child: Text(
                        '2020',
                        style: TextStyle(fontSize: 12, color: Colors.black),
                        maxLines: 1,
                      ),
                    ),
                    Text(
                      '年',
                      style: TextStyle(fontSize: 10, color: Color(u_2787de)),
                    ),
                  ],
                ),
              ),
            ),
            Expanded(
              flex: 1,
              child: Container(
                width: 10,
                child: Row(
                  children: [
                    Expanded(
                      child: Text(
                        'start' == dateFlag ? '1' : '12',
                        style: TextStyle(fontSize: 12, color: Colors.black),
                      ),
                    ),
                    Text(
                      '月',
                      style: TextStyle(
                        fontSize: 10,
                        color: Color(u_2787de),
                      ),
                    ),
                    SizedBox(width: 5),
                  ],
                ),
              ),
            ),
            Image.asset(
              'assets/images/2.0x/icon_date_spinner.png',
              width: width(8),
              height: height(20),
            ),
          ],
        ),
      ),
      onTap: () {
        ToastUtil.showBasicToast('时间选择');
      },
    );
  }*/

  ///搜索按钮
 /* Widget _searchBtn() {
    return Container(
      color: Color(u_2787de),
      margin: EdgeInsets.only(left: 10),
      width: 50,
      height: 25,
      child: OutlineButton(
        padding: EdgeInsets.all(0),
        child: Text(
          '搜索',
          style: TextStyle(
              color: Colors.white, fontSize: isLargeScreen ? 12.0 : 10.0),
        ),
        onPressed: () {},
      ),
    );
  }*/

  ///右边ListView表头
  /*Widget _buildListViewHeader() {
    return Container(
      color: Color(u_bbd4ee),
      height: 30,
      child: Flex(
        direction: Axis.horizontal,
        children: <Widget>[
          dividerVertical(),
          Expanded(
            flex: 1,
            child: Text(
              '序号',
              style: TextStyle(fontSize: isLargeScreen ? 12 : 10),
              textAlign: TextAlign.center,
            ),
          ),
          dividerVertical(),
          Expanded(
            flex: 2,
            child: Text(
              '类别',
              style: TextStyle(fontSize: isLargeScreen ? 12 : 10),
              textAlign: TextAlign.center,
            ),
          ),
          dividerVertical(),
          Expanded(
            flex: 2,
            child: Text(
              '次数',
              style: TextStyle(fontSize: isLargeScreen ? 12 : 10),
              textAlign: TextAlign.center,
            ),
          ),
          dividerVertical(),
          Expanded(
            flex: 2,
            child: Text(
              '金额（元）',
              style: TextStyle(fontSize: isLargeScreen ? 12 : 10),
              textAlign: TextAlign.center,
            ),
          ),
          dividerVertical(),
        ],
      ),
    );
  }*/

  ///右边ListView
  /*Widget _buildListView() {
    return ListView.builder(
      padding: EdgeInsets.only(top: 0.0), //Flutter listView 顶部有距离，无法置顶
      itemBuilder: (context, index) {
        return _buildListItem(index, _testData()[index]);
      },
      itemCount: _testData().length,
    );
  }*/

  ///ListView的Item
  /*Widget _buildListItem(int index, userData) {
    return Container(
      height: 30,
      color: (index % 2 == 0) ? Colors.white : Color(u_ffeff7fb),
      child: Row(
//        crossAxisAlignment: CrossAxisAlignment.stretch,
        children: [
          dividerVertical(),
          Expanded(
            flex: 1,
            child: Text(
              '${index + 1}',
              style: TextStyle(fontSize: isLargeScreen ? 12 : 10),
              textAlign: TextAlign.center,
            ),
          ),
          dividerVertical(),
          Expanded(
            flex: 2,
            child: Text(
              '类别',
              style: TextStyle(fontSize: isLargeScreen ? 12 : 10),
              textAlign: TextAlign.center,
            ),
          ),
          dividerVertical(),
          Expanded(
            flex: 2,
            child: Text(
              '次数',
              style: TextStyle(fontSize: isLargeScreen ? 12 : 10),
              textAlign: TextAlign.center,
            ),
          ),
          dividerVertical(),
          Expanded(
            flex: 2,
            child: Text(
              '金额（元）',
              style: TextStyle(fontSize: isLargeScreen ? 12 : 10),
              textAlign: TextAlign.center,
            ),
          ),
          dividerVertical(),
        ],
      ),
    );
  }*/

/*  List _testData() {
    List list = [];
    for (int i = 0; i < 50; i++) {
      list.add('UserBean()');
    }
    return list;
  }*/

  ///用ListView加载饼状图
/*  Widget _buildPieListView() {
    return ListView.separated(
      itemBuilder: (context, index) {
        return _buildPieItem(_pieList[index]);
      },
      separatorBuilder: (context, index) => Divider(
        height: height(20),
        color: Colors.transparent,
      ),
      itemCount: 3,
//      physics: NeverScrollableScrollPhysics(),
    );
  }

  ///Pie图
  Widget _buildPieItem(DrugPieData data) {
    return Container(
      padding: EdgeInsets.all(10),
      color: Colors.white,
      width: width(825),
      height: height(600),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(
            data.leftTopTitle,
            style: TextStyle(
              color: Color(u_333333),
              fontSize: 12,
              fontWeight: FontWeight.w300,
            ),
          ),
          Expanded(child: _initPieChart()),
        ],
      ),
    );
  }

  Widget _initPieChart() {
    return Container(
//      color: Colors.tealAccent,
      height: 500,
      width: 500,
      child: PieChart(_pieChartUtil.controller),
    );
  }

  void _testPieData() async {
    List<String> PARTIES = [
      '门诊单病种',
      '特药',
      '住院',
      '门慢门特',
      '门诊药店',
      '年度就诊',
      '基金支付',
    ];

    var random = Random(1);
    List<PieEntry> entries = List();
    for (int i = 0; i < 3; i++) {
      entries.add(
        PieEntry(
          value: ((random.nextDouble() * 100.0) + 100 / 5),
          label: PARTIES[i % PARTIES.length],
        ),
      );
    }
    _pieChartUtil.showPieChart(entries);
    setState(() {});
  }*/
}
